
package com.insigma.business.qrcode.soldier.service.impl;


import com.insigma.business.qrcode.common.service.SequenceGenerator;
import com.insigma.business.qrcode.common.util.AdminAreaCodeUtils;
import com.insigma.business.qrcode.soldier.dao.CommonSmsPoolDao;
import com.insigma.business.qrcode.soldier.dto.SequenceNameConstant;
import com.insigma.business.qrcode.soldier.entity.CommonSmsPoolDO;
import com.insigma.business.qrcode.soldier.request.CommonSmsPoolBSearcher;
import com.insigma.business.qrcode.soldier.service.CommonSmsPoolService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("commonSmsPoolService")
public class CommonSmsPoolServiceImpl implements CommonSmsPoolService {

    @Autowired(required = false)
    private CommonSmsPoolDao commonSmsPoolDao;
    @Autowired(required = false)
    private SequenceGenerator sequenceGenerator;

    
    @Override
    public List<CommonSmsPoolDO> search(final CommonSmsPoolBSearcher commonSmsPoolBSearcher) {
        if (Strings.isNotBlank(commonSmsPoolBSearcher.getAdminAreaCode())) {
            commonSmsPoolBSearcher.setAdminAreaCode(AdminAreaCodeUtils.getCutdAreaCode(commonSmsPoolBSearcher.getAdminAreaCode()));
        }
        return commonSmsPoolDao.search(commonSmsPoolBSearcher);
    }
   
    @Override
    public CommonSmsPoolDO get(final String id){
        return commonSmsPoolDao.get(id);
    }

    
    @Override
    public Integer insert(final CommonSmsPoolDO commonSmsPoolDO){
        commonSmsPoolDO.setId(sequenceGenerator.genKey(SequenceNameConstant.COMMON_SMS_POOL_ID));
        return commonSmsPoolDao.insert(commonSmsPoolDO);
    }

    
    @Override
    public Integer update(final CommonSmsPoolDO commonSmsPoolDO){
        return commonSmsPoolDao.update(commonSmsPoolDO);
    }

    
    @Override
    public Integer delete(final String id, final String modifierType, final String modifierId){
        return commonSmsPoolDao.delete(id,modifierType,modifierId);
    }

}
